open Signal;;

type item = string * sigTyp expression 
type t = {
    mutable wire : item list;
    mutable out : item list;
    mutable reg : item list;
}

let sym = {wire = [];out = [];reg = []}
let ( := ) (x:named) (e:sigTyp expression) = match x with
    | Var n -> sym.wire <- (n,e) :: sym.wire
    | Out n -> sym.out <- (n,e) :: sym.out
    | Reg n -> sym.reg <- (n,e) :: sym.reg
    | In _ -> ()

let wire = sym.wire
let out = sym.out
let reg = sym.reg

let string_of_sigList l = String.concat  " " (List.map (fun (n,e) -> n ^":"^(to_string e)) l)

let string_of_comp () = (string_of_sigList sym.wire) ^ "\n" ^
    (string_of_sigList sym.reg) ^ "\n" ^
    (string_of_sigList sym.out) ^ "\n" 



